/**
 * @Author: 陈瑞鹏
 * @Date:   2022-12-05 17:39:01
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-12-05 17:42:56
 */
import { Mediator } from "../pureMvc/patterns/mediator/Mediator";
import BaseGameScene from "./BaseGameScene";

import { INotification } from "../pureMvc/Interfaces";
import { GameFacade } from "./GameFacade";

export class MediatorGameScene extends Mediator {

  private displayObject: BaseGameScene = null;

  constructor(mediatorName: string, displayObject: BaseGameScene) {
    
    super(mediatorName);

    this.bindingDiplayObject(displayObject);
  }

  /**
   * 注册mediator
   */
  public registerMediator(): void {
    
    GameFacade.getInstance().registerMediator(this);
  }

  /**
   * 删除mediator
   */
  public removeMediator(): void {
    
    GameFacade.getInstance().removeMediator(this.getMediatorName());
  }

  /**
   * 绑定视图组件
   * @param displayObject 
   */
  private bindingDiplayObject(displayObject: BaseGameScene) {
    
    this.displayObject = displayObject;
  }

  /**
   * 绑定的事件 数组
   */
  public listNotificationInterests(): string[] {
    
    return this.displayObject.listNotificationInterests();
  }

  /**
   * 事件 响应方法
   * @param notification 
   */
  public handleNotification(notification: INotification): void {

    this.displayObject.handleNotification(notification);
  }
}